using System;
using System.Runtime.CompilerServices;

namespace Catastrophe.Initialize
{
	public class CatastropheMsg
	{
		public string Message { get; set; }

		public CatastropheMsgTypeEnum CatastropheMsgType { get; set; } = CatastropheMsgTypeEnum.Info;


		public int ExpireTime { get; set; }

		public bool IsRecord { get; set; }

		public Exception ExMsg { get; set; }

		public bool ShowDialog { get; set; }

		public int Times { get; set; }

		public string FirstTime { get; set; }

		public string LastTime { get; set; }

		public string TimeStamp { get; set; }

		public bool FisrtShow { get; set; } = true;


		public CatastropheMsg()
		{
		}

		public CatastropheMsg(string msg, int expireTime = 0)
			: this(msg, CatastropheMsgTypeEnum.Info, expireTime)
		{
		}

		public CatastropheMsg(string msg, CatastropheMsgTypeEnum CatastropheMsgType, int expireTime = 0)
		{
			this.Message = msg;
			this.ExpireTime = expireTime;
			this.CatastropheMsgType = CatastropheMsgType;
		}

		public override string ToString()
		{
			DefaultInterpolatedStringHandler defaultInterpolatedStringHandler;
			if (this.Times > 1)
			{
				defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(19, 5);
				defaultInterpolatedStringHandler.AppendFormatted(this.CatastropheMsgType);
				defaultInterpolatedStringHandler.AppendLiteral(":");
				defaultInterpolatedStringHandler.AppendFormatted(this.Message);
				defaultInterpolatedStringHandler.AppendLiteral(" TIMES:");
				defaultInterpolatedStringHandler.AppendFormatted(this.Times);
				defaultInterpolatedStringHandler.AppendLiteral(" LAST:");
				defaultInterpolatedStringHandler.AppendFormatted(this.LastTime);
				defaultInterpolatedStringHandler.AppendLiteral(" NOW:");
				defaultInterpolatedStringHandler.AppendFormatted(this.TimeStamp);
				return defaultInterpolatedStringHandler.ToStringAndClear();
			}
			defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 3);
			defaultInterpolatedStringHandler.AppendFormatted(this.CatastropheMsgType);
			defaultInterpolatedStringHandler.AppendLiteral(":");
			defaultInterpolatedStringHandler.AppendFormatted(this.Message);
			defaultInterpolatedStringHandler.AppendLiteral(" ");
			defaultInterpolatedStringHandler.AppendFormatted(this.TimeStamp);
			return defaultInterpolatedStringHandler.ToStringAndClear();
		}
	}
}
